# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=cantarell-fonts
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.201
pkgrel=3
arch=('any')
pkgdesc="Humanist sans serif font (mingw-w64)"
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-appstream-glib")
license=(custom:SIL)
url="https://www.gnome.org"
source=("https://download.gnome.org/sources/${_realname}/${pkgver}/${_realname}-${pkgver}.tar.xz")
sha256sums=('b61f64e5f6a48aa0abc7a53cdcbce60de81908ca36048a64730978fcd9ac9863')

prepare() {
  cd "${srcdir}"/${_realname}-$pkgver
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -rf build-${MINGW_CHOST}
  mkdir -p build-${MINGW_CHOST} && cd build-${MINGW_CHOST}
  cp -r "../${_realname}-$pkgver/prebuilt" \
    ${srcdir}/build-${MINGW_CHOST}

  MSYS2_ARG_CONV_EXCL="--prefix=;-Dfontsdir=" \
  ${MINGW_PREFIX}/bin/meson \
    --prefix=${MINGW_PREFIX} \
    --buildtype=plain \
    -Duseprebuilt=true \
    -Dbuildappstream=true \
    -Dfontsdir=${MINGW_PREFIX}/share/fonts/cantarell \
    "../${_realname}-${pkgver}"

  ninja
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  DESTDIR="${pkgdir}" ninja install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
